﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <link href="~/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="~/lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="~/lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
    <link href="~/Content/css/common.css" rel="stylesheet" type="text/css" />
    <script src="~/lib/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
    <script src="~/lib/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js"></script>
    <script>
        $(function () {
            $("#departmentCode").ligerComboBox({
                width: 120,
                cancelable: false,
                url: "GetAllUnits?isAll=1&ram" + Math.random(),
                valueField: "DepartmentCode",
                textField: "DepartmentName",
                valueFieldID: "hdnInDepartmentCode",
                value: -1,
            });
        });

        function UpdateAdverseEventDb() {
            var departmentCode = $("#hdnInDepartmentCode").val();
            if (IsEmpty(departmentCode) || departmentCode == "-1") {
                $.ligerDialog.error("请选择病区");
                return;
            }
            $("#btnUpdateAdverseEventDb").attr("disabled", true);
            $("#btnUpdateAdverseEventDb").attr("class", "l-button-disabled");
            $.ajax({
                url: "/UpdateDb/UpdateAdverseEventDb",
                type: "post",
                data: { departmentCode: departmentCode },
                success: function (r) {
                    var r = $.parseJSON(r);
                    if (r.Result == 1) {
                        $.ligerDialog.success("初始化成功！");
                    }
                    else if (r.Result == 0) {
                        $.ligerDialog.error(r.Body);
                    }
                    else {
                        $.ligerDialog.error("初始化失败！");
                    }
                    $("#btnUpdateAdverseEventDb").attr("disabled", false);
                    $("#btnUpdateAdverseEventDb").attr("class", "l-button");
                },
                error: function () {
                    $.ligerDialog.error("程序错误");
                }
            });
        }

        function UpdatePersonneltDb() {
            $("#btnUpdatePersonneltDb").attr("disabled", true);
            $("#btnUpdatePersonneltDb").attr("class", "l-button-disabled");
            $.ajax({
                url: "/UpdateDb/UpdatePersonneltDb",
                type: "post",
                data: {},
                success: function (r) {
                    var r = $.parseJSON(r);
                    if (r.Result == 1) {
                        $.ligerDialog.success("初始化成功！");
                    }
                    else if (r.Result == 0) {
                        $.ligerDialog.error(r.Body);
                    }
                    else {
                        $.ligerDialog.error("初始化失败！");
                    }
                    $("#btnUpdatePersonneltDb").attr("disabled", false);
                    $("#btnUpdatePersonneltDb").attr("class", "l-button");
                },
                error: function () {
                    $.ligerDialog.error("程序错误");
                }
            });
        }
    </script>
</head>
<body>
    <div class="searchbar">
        <div class="sblabel">病区：</div>
        <div class="sbligerControl">
            <input type="text" id="departmentCode" />
        </div>
        <div class="sbligerButton">
            <input id="btnUpdateAdverseEventDb" type="button" value="初始化不良事件" class="l-button" onclick="UpdateAdverseEventDb();" style="width:120px;" />
        </div>
        <div class="sbligerButton">
            <input id="btnUpdatePersonneltDb" type="button" value="初始人员档案" class="l-button" onclick="UpdatePersonneltDb();" style="width:120px;display:none;" />
        </div>
    </div>
</body>
</html>
